﻿Imports Microsoft.Reporting.WebForms
Public Class Reportes_Consolidados
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            'Session("usuarioId") = 1
            'Session("profesion") = "123"
            'Session("nombre") = "123"
            If Session("usuarioId") Is Nothing Then
                Response.Redirect("loguin.aspx")
            End If
            If Not IsPostBack Then
                lbprofesion.Text = Session("profesion").ToString()
                lbnombre.Text = Session("nombre").ToString()
            End If
        Catch ex As Exception
            Response.Write(ex.Message)
        End Try
    End Sub

    Protected Sub Btn_Consultar_Click(sender As Object, e As EventArgs) Handles Btn_Consultar.Click
        Try
            Dim rds As ReportDataSource = New ReportDataSource
            rds.Name = "DataSet1"
            Rv_reporte.LocalReport.DataSources.Clear()
            Select Case Ddl_Reporte.SelectedValue
                Case 0
                    Rv_reporte.LocalReport.ReportPath = "Reporte_socio_economico.rdlc"
                    rds.DataSourceId = "Ods_socioeconomico"
                Case 1
                    Rv_reporte.LocalReport.ReportPath = "Reporte_psico_social.rdlc"
                    rds.DataSourceId = "Ods_psico_social"
                Case 2
                    Rv_reporte.LocalReport.ReportPath = "Reporte_medico_gediatra.rdlc"
                    rds.DataSourceId = "Ods_medico_geriatra"
                Case 3
                    Rv_reporte.LocalReport.ReportPath = "Reporte_nutricional.rdlc"
                    rds.DataSourceId = "Ods_nutricional"
                Case 4
                    Dim rds2 As ReportDataSource = New ReportDataSource
                    Dim rds3 As ReportDataSource = New ReportDataSource
                    Dim rds4 As ReportDataSource = New ReportDataSource
                    Rv_reporte.LocalReport.ReportPath = "Reporte_Full.rdlc"
                    rds.DataSourceId = "Ods_socioeconomico"
                    rds2.Name = "DataSet2"
                    rds2.DataSourceId = "Ods_psico_social"
                    rds3.Name = "DataSet3"
                    rds3.DataSourceId = "Ods_medico_geriatra"
                    rds4.Name = "DataSet4"
                    rds4.DataSourceId = "Ods_nutricional"
                    Rv_reporte.LocalReport.DataSources.Add(rds2)
                    Rv_reporte.LocalReport.DataSources.Add(rds3)
                    Rv_reporte.LocalReport.DataSources.Add(rds4)
                Case Else
                    Exit Sub
            End Select
            Rv_reporte.LocalReport.SetParameters(New ReportParameter("SrutaServer", Server.MapPath("~/images_perfil/"), True))
            Rv_reporte.LocalReport.EnableExternalImages = True
            Rv_reporte.LocalReport.DataSources.Add(rds)
            Rv_reporte.LocalReport.Refresh()
        Catch ex As Exception

        End Try
    End Sub

End Class